<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>更新书籍</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
        }
        .container {
            width: 80%;
            max-width: 800px;
            margin: 30px auto;
            padding: 20px;
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h1 {
            text-align: center;
            color: #333;
            margin-bottom: 20px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
            color: #555;
        }
        .form-control {
            width: 100%;
            padding: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 16px;
            line-height: 1.5;
        }
        .form-control:focus {
            border-color: #007bff;
            outline: none;
            box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.25);
        }
        .btn {
            display: inline-block;
            padding: 10px 20px;
            font-size: 16px;
            font-weight: bold;
            text-align: center;
            text-decoration: none;
            border-radius: 5px;
            border: none;
            cursor: pointer;
            color: #fff;
            background-color: #007bff;
            transition: background-color 0.3s;
            margin-top: 10px;
        }
        .btn:hover {
            background-color: #0056b3;
        }
        .btn-secondary {
            background-color: #6c757d;
        }
        .btn-secondary:hover {
            background-color: #5a6268;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>更新书籍</h1>
    <form th:action="@{/books/update}" method="post">
        <input type="hidden" th:value="${book.id}" name="id"/>
        <div class="form-group">
            <label for="name" class="form-label">书名:</label>
            <input type="text" id="name" name="name" th:value="${book.name}" class="form-control" required>
        </div>
        <div class="form-group">
            <label for="author" class="form-label">作者:</label>
            <input type="text" id="author" name="author" th:value="${book.author}" class="form-control" required>
        </div>
        <div class="form-group">
            <label for="price" class="form-label">价格:</label>
            <input type="number" step="0.01" id="price" name="price" th:value="${book.price}" class="form-control" required>
        </div>
        <div class="form-group">
            <!-- category -->
            <label for="category" class="form-label">分类:</label>
       <input type="text" id="category" name="category" th:value="${book.category}" class="form-control" required>
        </div>
        <div class="form-group">
            <label for="pnum" class="form-label">页数:</label>
            <input type="number" id="pnum" name="pnum" th:value="${book.pnum}" class="form-control" required>
        </div>
        <div class="form-group">
            <label for="imgurl" class="form-label">图片 URL:</label>
            <input type="text" id="imgurl" name="imgurl" th:value="${book.imgurl}" class="form-control">
        </div>
        <div class="form-group">
            <label for="description" class="form-label">描述:</label>
            <textarea id="description" name="description" th:text="${book.description}" class="form-control"></textarea>
        </div>
        <div class="form-group">
            <label for="sales" class="form-label">销量:</label>
            <input type="number" id="sales" name="sales" th:value="${book.sales}" class="form-control" required>
        </div>
        <button type="submit" class="btn">更新书籍</button>
    </form>
    <a href="/books" class="btn btn-secondary">返回书籍列表</a>
</div>
</body>
</html>
